package me.leiusual.sharing.ui.shop

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations.switchMap
import androidx.lifecycle.ViewModel
import me.leiusual.sharing.api.model.BusinessType
import me.leiusual.sharing.repository.BusinessRepository
import me.leiusual.sharing.repository.model.Data
import me.leiusual.sharing.util.extension.toLiveData
import javax.inject.Inject

/**
 * author: leiusual
 * create on: 2019-07-29
 * description:
 */
class ShopBusinessViewModel @Inject constructor(
    private val businessRepository: BusinessRepository
) : ViewModel() {

  // 类别

  private val _businessType = MutableLiveData<Unit>()
  val businessType: LiveData<Data<List<BusinessType>>> = switchMap(_businessType) {
    businessRepository.businessApply().toLiveData()
  }

  fun businessType() {
    _businessType.value = Unit
  }
}